#include<iostream> 
using namespace std;
typedef long long LL;

const int N = 10e5 + 10;
int f[N];
int n,m;
int main()
{
	LL ret = 0;
	cin >> n >> m;
	int x, y;
	cin >> x;
	for(int i  = 1; i < m; i++)
	{
		cin >> y;
		if(x > y) f[y]++,f[x]--;
		else f[x]++,f[y]--;
		
		x = y;
	}
	
	for(int i = 1; i <= n; i++)
	{
		f[i] = f[i - 1] + f[i];
	}
	
	for(int i = 1; i < n; i++)
	{
		LL a,b,c;
		cin >> a >> b >> c;
		ret += min(a * f[i], c + b * f[i]);
	}
	cout << ret;
	return 0;
 } 
